/**
 * @description error 404 路由
 * @author 双越老师
 */

const router = require('koa-router')()

// 故意制造一个错误页面进行redict跳转
router.get('/get-an-error', async (ctx, next) => {
  throw Error()
  this.body = { 
    msg: 'xxx'
  }
})
 
// error
router.get('/error', async (ctx, next) => {
  await ctx.render('error', {
    message: '错误了~',
    error: {
      status: 500
    }
  })
})
 
// 404
router.get('*', async (ctx, next) => {
  await ctx.render('404')
})
 
module.exports = router